package com.andy.blog.admin.dto;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created by andy on 2023/7/21 18:50
 */
public class TrieNodeDTO {

    /**
     * 关键词结束标识（叶子节点）
     */
    private boolean isKeywordEnd = false;
    /**
     * 子节点(key:子节点字符, value:子节点类型)
     */
    private final Map<Character, TrieNodeDTO> subNodes = new ConcurrentHashMap<>();

    public boolean isKeywordEnd() {
        return isKeywordEnd;
    }

    public void setKeywordEnd(boolean keywordEnd) {
        isKeywordEnd = keywordEnd;
    }

    // 添加子节点
    public void addSubNode(Character c, TrieNodeDTO node) {
        subNodes.put(c, node);
    }

    // 获取子节点
    public TrieNodeDTO getSubNode(Character c) {
        return subNodes.get(c);
    }
}
